Component({
  properties: {
    frameTitle: {
      type: String,
      value: '温馨提示'
    }
  },
  data: {
    title: "用户隐私保护提示",
    desc1: "感谢您使用本游戏，您使用本游戏前应当阅井同意",
    urlTitle: "《用户隐私保护指引》",
    desc2: "当您点击同意并开始时用产品服务时，即表示你已理解并同息该条款内容，该条款将对您产生法律约束力。如您拒绝，将无法进入游戏。",
    innerShow: false,
    height: 0,
  },
  lifetimes: {
    attached: function () {
      if (wx.getPrivacySetting) {
        wx.getPrivacySetting({
          success: res => {
            console.log("是否需要授权：", res.needAuthorization, "隐私协议的名称为：", res.privacyContractName)
            if (res.needAuthorization) {
              this.popUp()
            } else {
              this.triggerEvent('change')
            }
          },
          fail: () => {},
          complete: () => {},
        })
      } else {
        // 低版本基础库不支持 wx.getPrivacySetting 接口，隐私接口可以直接调用
        this.triggerEvent("disagree")
      }
    },
  },
  methods: {
    show() {
      this.setData({
        innerShow: true
      })
    },
    handleDisagree(e) {
      this.triggerEvent('refuse')
      this.disPopUp()
      wx.navigateBack()
    },
    handleAgree(e) {
      this.triggerEvent('agree')
      this.disPopUp()
    },
    popUp() {
      this.setData({
        innerShow: true
      })
    },
    disPopUp() {
      this.setData({
        innerShow: false
      })
    },
    handleOpenPrivacyContract() {
      // 打开隐私协议页面
      wx.openPrivacyContract({
        success: () => {
          console.log('success')
        }, // 打开成功
        fail: () => {
          console.log('fail')

        }, // 打开失败
        complete: () => {}
      })
    },
  }
})